<?php

namespace App\Transformers\Traits;

use App\Transformers\MediaTransformer;
use Illuminate\Database\Eloquent\Model;

trait WithTransformerMedia
{
    public function includeMedia(Model $model)
    {
        $media = $model->media;
        if (!$media) {
            return $this->null();
        }
        return $this->item($media, new MediaTransformer());
    }
}